<include file="Public/min-header" />
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <style>
        tbody img{
            height: 80px;
            width: 120px;
            object-fit: cover;
            display: block;
        }
    </style>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 申请实名认证列表</h3>
                </div>
                <div class="navbar navbar-default">
                    <div class="collapse navbar-collapse">
                        <form class="navbar-form form-inline" action="{:U('Certification/examine')}" method="post">
                            <div class="form-group">
                                <input type="text" name="username" class="form-control" placeholder="姓名" value='{$username}'>
                            </div>
                            <!-- <div class="form-group">
                                <select name="shipping_status" class="input-sm" style="width:100px;">
                                    <option value="">发货状态</option>
                                    <option value="0">未发货</option>
                                    <option value="1">已发货</option>
                                    <option value="2">部分发货</option>
                                </select>
                            </div> -->
                            <button type="submit" class="btn btn-primary" data-toggle='tooltip' data-original-title="查询">查询</button>
                            <a href="javascript:;" data-url="{:U('Certification/right_del')}" onclick="delAll(this,'right')"
                                class="btn btn-primary">批量删除</a>
                        </form>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                                <tr>
                                    <td class="text-left"><input type="checkbox" onclick="choosebox(this)">全选</td>
                                    <td class="text-center">ID</td>
                                    <td class="text-center" style='width: 10%'>姓名</td>
                                    <td class="text-center">身份证号码</td>
                                    <td class="text-center">手持身份证正面照片</td>
                                    <td class="text-center">身份证正面照片</td>
                                    <td class="text-center">身份证反面照片</td>
                                    <td class="text-center">审核状态</td>
                                    <td class="text-center">操作</td>
                                </tr>
                            </thead>
                            <tbody>
                                <volist name="lists" id="list">
                                    <tr>
                                        <td><input type="checkbox" name="right[]" value="{$list.sm_id}"></td>
                                        <td class="text-center">{$list.sm_id}</td>
                                        <td class="text-center">{$list.username}</td>
                                        <td class="text-center">{$list.card}</td>
                                        <td class="text-center">
                                            <notempty name="list.szheng">
                                                <img src="{$list.szheng}"
                                                    alt="" data-toggle="modal" data-target="#myModal"/>
                                            </notempty>
                                        </td>
                                        <td class="text-center">
                                            <notempty name="list.zheng">
                                                <img src="{$list.zheng}"
                                                    alt="" data-toggle="modal" data-target="#myModal"/>
                                            </notempty>
                                        </td>
                                        <td class="text-center">
                                            <notempty name="list.fan">
                                                <img src="{$list.fan}"
                                                    alt="" data-toggle="modal" data-target="#myModal"/>
                                            </notempty>
                                        </td>
                                        <td class="text-center">
                                            <if condition="$list['status'] eq 1">
                                                待审核
                                            </if>
                                            <if condition="$list['status'] eq 0">
                                                驳回
                                            </if>
                                        </td>
                                        <td class="text-center">
                                            <a href="#" id="tongguo" val="{$list['sm_id']}" data-toggle="tooltip" title=""
                                                class="btn btn-info" data-original-title="审核通过">审核通过</a>
                                            <if condition="$v['status'] eq 0">
                                                <a href="#" id="bohui" val="{$list['sm_id']}" data-toggle="tooltip"
                                                    title="" class="btn btn-default" data-original-title="驳回">驳回</a>
                                            </if>
                                            <a href="#" id="del" val="{$list['sm_id']}" data-toggle="tooltip" class="btn btn-danger"
                                                title="" data-original-title="删除"><i class="fa fa-trash-o"></i></a>

                                        </td>
                                    </tr>
                                </volist>
                            </tbody>
                        </table>
                        <div class="pull-center">
                            {$page}
                        </div>
                    </div>
                </div>
            </div>
        </div> <!-- /.row -->
    </section>
    <!-- /.content -->


    <!-- 弹窗 -->

    <style>
         
        .carousel{
            /* width: 600px; */
            height: 400px;
        } 
        .carousel-inner{
            height: 100%;
            width: 100%;
        }
        .carousel-inner .item{
            height: 100%;
            width: 100%;
            overflow: scroll
        }
        .carousel-inner img{
            height: 100% !important;
            width: 100%;
            object-fit: contain;
            transform-origin: 0 0;
        }
        .carouselImg.active img{
            /* cursor: move; */
        }
    </style>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">认证资料</h4>
                </div>
                <div class="modal-body">
                    <div id="myCarousel" class="carousel" data-interval="false"	>
                        <!-- 轮播（Carousel）指标 -->
                        <ol class="carousel-indicators">
                        </ol>
                        <!-- 轮播（Carousel）项目 -->
                        <div class="carousel-inner">
                            
                        </div>
                        <!-- 轮播（Carousel）导航 -->
                        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                    </div>
                </div>
                <div class="modal-footer">
                    <a title="放大" class="btn btn-default zoomPlus">
                        <i class="fa fa-plus"></i>
                    </a>
                    <a title="缩小" class="btn btn-default zoomMinus">
                        <i class="fa fa-minus"></i>
                    </a>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
        <!-- /弹窗 -->
    </div>
    <!-- /.content-wrapper -->
    <script>

        // 模态框
        $('#myModal').on('show.bs.modal', function () {
            // 执行一些动作...  

        })

        // 放大缩小
        $(document).on('click','.zoomPlus',function(){            
            var item = $('.carouselImg.active img')
            var zoom = parseFloat( item.attr('zoom') || 1)
            if( zoom > 5 ) return false;
            zoom += 0.5
            item.attr('zoom',zoom).css('transform','scale('+zoom+')')
        })
        // 放大缩小
        $(document).on('click','.zoomMinus',function(){            
            var item = $('.carouselImg.active img')
            var zoom = parseFloat( item.attr('zoom') || 1)
            zoom -= 0.5
            if( zoom < 1 ) return false;
            item.attr('zoom',zoom).css('transform','scale('+zoom+')')
        })

        // 查看大图
        $(document).on('click','img[data-target="#myModal"]',function(){
            var lists = $(this).parent().parent().find('img[data-target="#myModal"]');
            console.log($(this).index())
            var li = '';
            var html = '';
            var index = lists.length - 1;
            var curentUrl = $(this).attr('src')
            for(var i = 0;i < lists.length; i++)
            {
                if( lists[i].src == curentUrl ) index = i;
                li += '<li data-target="#myCarousel" data-slide-to="'+i+'" class="'+(i==index?'active':'')+'"></li>';
                html += '<div class="item carouselImg '+(i==index?'active':'')+'">\
                                <img src="'+lists[i].src+'" alt="">\
                            </div>';
            }
            $('.carousel-indicators').html(li)
            $('.carousel-inner').html(html)
        })

        // 

        $(document).ready(function () {
            ajax_get_table('search-form2', 1);
        });
        $(document).on('click', '#tongguo', function () {
            var id = $(this).attr('val');
            update_shop_status(id, 2);
        });

        $(document).on('click', '#bohui', function () {
            var id = $(this).attr('val');
            update_shop_status(id, 0);
        });
        //修改店铺状态
        function update_shop_status(id, status) {
            $.ajax({
                url: "/index.php?m=Admin&c=Certification&a=update_certification_status",
                type: "post",
                data: {
                    id: id,
                    status: status
                },
                dataType: "json",
                success: function (msg) {
                    if (msg.result == 400 || msg.result == '400') {
                        alert('审核失败');
                    } else {
                        alert('审核成功');
                        window.location.href = "";
                    }
                }
            });
        }



        // ajax 抓取页面
        function ajax_get_table(tab, page) {
            cur_page = page; //当前页面 保存为全局变量
            $.ajax({
                type: "POST",
                url: "/index.php/Admin/user/ajaxindex/p/" + page, //+tab,
                data: $('#' + tab).serialize(), // 你的formid
                success: function (data) {
                    $("#ajax_return").html('');
                    $("#ajax_return").append(data);
                }
            });
        }

        // 点击排序
        function sort(field) {
            $("input[name='order_by']").val(field);
            var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
            $("input[name='sort']").val(v);
            ajax_get_table('search-form2', cur_page);
        }

        //批量删除
        function choosebox(o) {
            var vt = $(o).is(':checked');
            if (vt) {
                $('input[type=checkbox]').prop('checked', vt);
            } else {
                $('input[type=checkbox]').removeAttr('checked');
            }
        }

        // 删除
        $(document).on('click', '#del', function () {
            var id = $(this).attr('val');
            if (confirm('确定要删除吗?')) {
                $.ajax({
                    url: "/index.php?m=Admin&c=Certification&a=Certification_del",
                    type: "post",
                    data: {
                        id: id
                    },
                    dataType: "json",
                    success: function (msg) {
                        if (msg.result == 400 || msg.result == '400') {
                            alert('删除失败');
                        } else {
                            alert('删除成功');
                            window.location.href = "";
                        }
                    }
                });
            }

            return false;
        });
    </script>
    </body>

    </html>